package com.papercut.service;

import java.util.ArrayList;
import java.util.List;

import com.papercut.purchase.PurchaseEntity;
import com.papercut.purchase.PurchaseItem;

import android.app.IntentService;
import android.app.Service;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.util.Log;
import android.util.TypedValue;

public class RestService extends IntentService {
	
	public static final int getTransaction = 1;
	public static final int authenticateSwipe = 2;
	public static final int register = 3;
	//public static final int DELETE = 4;
	
	public static final String type = "com.objection.papercut.restClient.RestService.type";
	public static final String transactionID = "com.objection.papercut.restClient.RestService.transactionID";
	public static final String swipe = "com.objection.papercut.restClient.RestService.swipe";
	public static final String phoneNumber = "com.objection.papercut.restClient.RestService.phoneNumber";
	public static final String deviceID = "com.objection.papercut.restClient.RestService.deviceID";
	
	
	public RestService() {
		super("restService");
	}
	
	
	@Override
	protected void onHandleIntent(Intent intent) {
		
	}

	public PurchaseEntity getTranscation(int transactionID) {
		Log.d("Service", "get transaction...");
		return RestClient.getTransaction(transactionID);
	}
	
	public boolean authenticateSwipe(String swipe) {
		Log.d("Service", "authenticate swipe...");
		return RestClient.authenticateSwipe(swipe);
	}
	
	public boolean register(String phone, String device, String swipe) {
		Log.d("Service", "register device...");
		return RestClient.register(phone, device, swipe);
	}
	
	public boolean transferMoney(String deviceID, String phoneNumber, String amount) {
		Log.d("Service", "transfer money...");
		return RestClient.transferMoney(deviceID, phoneNumber, amount);
	}
	
	
	public class LocalBinder extends Binder {
        public RestService getService() {
            return RestService.this;
        }
        
    }
	

    @Override
    public IBinder onBind(Intent intent) {
    	Log.i("Binder", mBinder.getClass().toString());
        return mBinder;
    }

    // This is the object that receives interactions from clients.  See
    // RemoteService for a more complete example.
    private IBinder mBinder = new LocalBinder();

}
